package se.webbzon.boltzmann.effect;

import se.webbzon.boltzmann.resource.Resources;
import se.webbzon.oschi01.worldarea.WorldArea;
import se.webbzon.oschi01.worldobject.WorldStaticObject;
import se.webbzon.oschi01.worldobject.appearance.Appearance3D;
import se.webbzon.oschi01.worldobject.appearance.SimpleModelAppearance3D;

public class IceBlockEffect extends WorldStaticObject implements Effect {
	
	// The parent of this effect
	private final WorldStaticObject parent;
	
	/*============================================================
	Constructors
	============================================================*/
	
	/** Creates a new ice block effect. **/
	public IceBlockEffect(WorldStaticObject parent) {
		super(0,createAppearance());
		this.parent = parent;
	}
	
	/*============================================================
	Public Methods
	============================================================*/

	@Override public void launch(WorldArea world) {
		world.createInstance(this);
		setPosition(parent.getX(),parent.getY(),parent.getZ());
		setSize(parent.getWidth(),parent.getHeight(),parent.getDepth());
		setRotation(0,1,0,2*Math.PI*Math.random());
	}

	@Override public void terminate(WorldArea world) {
		world.destroyInstance(this);
	}
	
	/*============================================================
	Private Methods
	============================================================*/
	
	private static final Appearance3D createAppearance() {
		return new SimpleModelAppearance3D(2,Resources.getModelSet("ice_block_large"));
	}

}
